package com.qihoo360.mobilesafe.opti.powerctl.ui.widget;

import com.qihoo360.mobilesafe.opti.powerctl.R;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.FrameLayout;
import android.widget.ImageView;

public class RotatePointerAniView extends FrameLayout {

	private ImageView mPointer;

	public RotatePointerAniView(Context context, AttributeSet attrs) {
		super(context, attrs);
		inflate(context, R.layout.rotate_pointer_ani_view, this);
		mPointer = (ImageView) findViewById(R.id.img_pointer_big);
	}

	private  int currentDegree ; 
	public void start(int newDegree) {
		float f1 = mPointer.getWidth() / 2.0F;
		float f2 = mPointer.getHeight() / 2.0F;
		Log.v("fan","start:f1:" + f1);
		Log.v("fan","start:f2:" + f2);
		RotateAnimation animation = new RotateAnimation(this, f1, f2);
		if(newDegree > 215) newDegree = 215;
	
		animation.a(currentDegree, newDegree);
		currentDegree = newDegree;
		animation.setFillEnabled(true);
		animation.setDuration(1000);
		animation.setFillAfter(true);
		mPointer.startAnimation(animation);
	}

}
